package com.ssy.lingxi.order.entity;

import com.fasterxml.jackson.annotation.JsonManagedReference;
import com.ssy.lingxi.order.handler.converter.JpaJsonToDeliveryPlanDayConverter;
import com.ssy.lingxi.order.model.bo.DeliveryPlanDayBO;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 送货计划-物料订单详情
 * @author czh
 * @version 2.0.0
 * @date 2021-09-23
 */
@Entity
@Table(schema = "public", name = "ord_delivery_plan_order")
public class DeliveryPlanOrderDO implements Serializable {

    /**
     * 主键Id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ord_delivery_plan_order_seq")
    @SequenceGenerator(sequenceName = "ord_delivery_plan_order_seq", name = "ord_delivery_plan_order_seq", allocationSize = 1)
    private Long id;

    /**
     * 上级会员，多对一单向关联
     */
    @JsonManagedReference
    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "plan_product_id", referencedColumnName = "id")
    private DeliveryPlanProductDO deliveryPlanProduct;

    /**
     * 送货计划id
     */
    @Column
    private Long planId;

    /**
     * 商品skuId,物料编号
     */
    @Column
    private String skuId;

    /**
     * 订单编号
     */
    @Column(columnDefinition = "varchar(20)")
    private String orderNo;

    /**
     * 订单摘要
     */
    @Column(columnDefinition = "varchar(20)")
    private String orderDigest;

    /**
     * 下单时间
     */
    @Column(columnDefinition = "timestamp")
    private LocalDateTime createTime;

    /**
     * 采购数量
     */
    @Column(columnDefinition = "decimal")
    private BigDecimal purchaseCount;

    /**
     * 收货数量
     */
    @Column(columnDefinition = "decimal")
    private BigDecimal receiveCount;

    /**
     * 在途数量
     */
    @Column(columnDefinition = "decimal")
    private BigDecimal transitCount;

    /**
     * 待送货数量
     */
    @Column(columnDefinition = "decimal")
    private BigDecimal leftCount;

    /**
     * 计划送货数量
     */
    @Column(columnDefinition = "decimal")
    private BigDecimal planCount;

    /**
     * 收货人地址id
     */
    @Column
    private Long consigneeId;

    /**
     * 订单商品id
     */
    @Column
    private Long orderProductId;

    /**
     * 收货人姓名
     */
    @Column(columnDefinition = "varchar(20)")
    private String consignee;

    /**
     * 省名称
     */
    @Column(columnDefinition = "varchar(20)")
    private String provinceName;

    /**
     * 市名称
     */
    @Column(columnDefinition = "varchar(20)")
    private String cityName;

    /**
     * 区名称
     */
    @Column(columnDefinition = "varchar(20)")
    private String districtName;

    /**
     * 街道名称
     */
    @Column(columnDefinition = "varchar(20)")
    private String streetName;

    /**
     * 详细地址
     */
    @Column(columnDefinition = "varchar(20)")
    private String address;

    /**
     * 手机号码
     */
    @Column(columnDefinition = "varchar(20)")
    private String phone;

    /**
     * 计划送货物料订单详情集合
     */
    @Convert(converter = JpaJsonToDeliveryPlanDayConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<DeliveryPlanDayBO> planDays;

    public String getSkuId() {
        return skuId;
    }

    public void setSkuId(String skuId) {
        this.skuId = skuId;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public DeliveryPlanProductDO getDeliveryPlanProduct() {
        return deliveryPlanProduct;
    }

    public void setDeliveryPlanProduct(DeliveryPlanProductDO deliveryPlanProduct) {
        this.deliveryPlanProduct = deliveryPlanProduct;
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public Long getPlanId() {
        return planId;
    }

    public void setPlanId(Long planId) {
        this.planId = planId;
    }

    public String getOrderDigest() {
        return orderDigest;
    }

    public void setOrderDigest(String orderDigest) {
        this.orderDigest = orderDigest;
    }

    public LocalDateTime getCreateTime() {
        return createTime;
    }

    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }

    public Long getOrderProductId() {
        return orderProductId;
    }

    public void setOrderProductId(Long orderProductId) {
        this.orderProductId = orderProductId;
    }

    public BigDecimal getPurchaseCount() {
        return purchaseCount;
    }

    public void setPurchaseCount(BigDecimal purchaseCount) {
        this.purchaseCount = purchaseCount;
    }

    public BigDecimal getReceiveCount() {
        return receiveCount;
    }

    public void setReceiveCount(BigDecimal receiveCount) {
        this.receiveCount = receiveCount;
    }

    public BigDecimal getTransitCount() {
        return transitCount;
    }

    public void setTransitCount(BigDecimal transitCount) {
        this.transitCount = transitCount;
    }

    public BigDecimal getLeftCount() {
        return leftCount;
    }

    public void setLeftCount(BigDecimal leftCount) {
        this.leftCount = leftCount;
    }

    public BigDecimal getPlanCount() {
        return planCount;
    }

    public void setPlanCount(BigDecimal planCount) {
        this.planCount = planCount;
    }

    public Long getConsigneeId() {
        return consigneeId;
    }

    public void setConsigneeId(Long consigneeId) {
        this.consigneeId = consigneeId;
    }

    public String getConsignee() {
        return consignee;
    }

    public void setConsignee(String consignee) {
        this.consignee = consignee;
    }

    public String getProvinceName() {
        return provinceName;
    }

    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public String getDistrictName() {
        return districtName;
    }

    public void setDistrictName(String districtName) {
        this.districtName = districtName;
    }

    public String getStreetName() {
        return streetName;
    }

    public void setStreetName(String streetName) {
        this.streetName = streetName;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public List<DeliveryPlanDayBO> getPlanDays() {
        return planDays;
    }

    public void setPlanDays(List<DeliveryPlanDayBO> planDays) {
        this.planDays = planDays;
    }
}
